package com.pk.platform.business.data.dao.impl;

import java.util.ArrayList;
import java.util.List;

import com.pk.platform.business.core.dao.impl.GenericDaoImpl;
import com.pk.platform.business.data.dao.IPackDao;
import com.pk.platform.domain.data.Pack;
import com.pk.platform.util.StringConverter;

public class PackDaoImpl extends GenericDaoImpl implements IPackDao {

	public int queryPackNameCount(String name, String id) {
		String sql = "select count(id) from p_pack where packName = ?";
		List<Object> param = new ArrayList<Object>();
		param.add(name);
		if(StringConverter.isNotNull(id))
		{
			sql += " and id <> ?";
			param.add(id);
		}
		int count = this.getSjt().queryForInt(sql, param.toArray());
		return count;
	}
	
	public Pack queryPackByName(String name)
	{
		String hql = "from Pack p where p.packName = ?";
		List<Pack> list = this.getHibernateTemplate().find(hql, new Object[]{name});
		if(list.size() > 0)
		{
			return list.get(0);
		}
		return null;
	}

}
